<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .el-form-item__content{
            margin-left: 0!important;
        }
    </style>
</head>

<body>
    <div id="app">
        <el-form ref="form" :rules="rules" :model="form" label-width="300px">
            <el-form-item label="发货人电话" prop="phone">
                <el-input  v-model="form.phone"></el-input>
                <el-button>确认</el-button>
            </el-form-item>
        </el-form>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.0/vue.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.3/index.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data() {
                // 此处自定义校验手机号码js逻辑
                var phoneReg = /^[1][3,4,5,7,8][0-9]{9}$/
                var validatePhone = (rule, value, callback) => {
                    if (!value) {
                        return callback(new Error('号码不能为空!!'))
                    }
                    setTimeout(() => {
                        if (!phoneReg.test(value)) {
                            callback(new Error('格式有误'))
                        } else {
                            callback()
                        }
                    }, 100)
                }
                return {
                    form: {
                        phone: '',
                    },
                    // 校验规则
                    rules: {
                        // 校验手机号码，主要通过validator来指定验证器名称
                        phone: [{
                            required: true, // required就是这个框必须填写
                            validator: validatePhone, // 规则
                            trigger: 'blur' // blur失去焦点，事件何时触发
                        }]
                    },
                }
            }
        });
    </script>
</body>

</html>